import os
import yaml
from config import BASE_PATH
from tools.tool_logger import *

def read_yaml(filename):
    logger.info(f'读取yaml文件开始,读取文件为：{filename}')
    try:
        file_path = BASE_PATH + os.sep + "data" + os.sep + filename
        data = []
        with open(file_path, "r", encoding='utf-8') as f:
            case_data = yaml.safe_load(f)
            for i in case_data:
                data.append(
                    (i.get('test_num'),
                     i.get('test_title'),
                     i.get('test_data'),
                     i.get('expect')))
            return data
    except Exception as e:
        logger.error(f'读取yaml文件失败，报错信息为：{e}')


if __name__ == '__main__':
    print(read_yaml("data_test_login.yaml"))